<template>
  <div>
    <div>
      <van-field
        class="input"
        v-model="value"
        label="主节点"
        placeholder="请输入企业名称或企业编码"
      />
      <van-field
        class="input"
        v-model="value"
        label="关联关系"
        placeholder="点击选择关联关系"
        @click="showPopup"
      />
      <van-popup v-model="show" position="bottom">
        <van-picker
          title="选择关联关系"
          show-toolbar
          :columns="columns"
          @confirm="onConfirm"
          @cancel="onCancel"
          @change="onChange"
        />
      </van-popup>
    </div>
    <van-button type="info" block style="width: 90%; margin: 100px auto">查询</van-button>
  </div>
</template>

<script>
import Vue from "vue";
import { Field, Picker, Popup, Toast } from "vant";

Vue.use(Field);
Vue.use(Picker);
Vue.use(Popup);

export default {
  data() {
    return {
      value: "",
      show: false,
      columns: ["上下游关联关系", "集团关联关系", "相似关联关系"],
    };
  },
  methods: {
    onConfirm(value, index) {
      Toast(`当前值：${value}, 当前索引：${index}`);
    },
    onChange(picker, value, index) {
      Toast(`当前值：${value}, 当前索引：${index}`);
    },
    showPopup() {
      this.show = true;
    },
    onCancel() {
      Toast("取消");
      this.show = false;
    },
  },
};
</script>

<style scoped>
.input {
  margin-top: 30px;
}
</style>